#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f;
ll dp[510][510];
ll num[510][510];

int main()
{
    IOS;
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            cin>>num[i][j];
        }
    }
    ll ans=-INF;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            dp[i][j]=dp[i-1][j]+num[i][j];
        }
        for(ll k=0;k<i;k++){
            ll sum=-INF;
            for(ll j=1;j<=m;j++){
                if(sum<0){
                    sum=dp[i][j]-dp[k][j];
                }
                else {
                    sum+=dp[i][j]-dp[k][j];
                }
                ans=max(sum,ans);
            }
        }
    }
    cout<<ans<<endl;
    getchar();
    getchar();
    return 0;
}
